using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Decisions.HL7.Message;
using DecisionsFramework;

namespace Decisions.HL7.Message
{
    public class IdentifierTypeAttribute:RuleAttribute
    {
        private Dictionary<HL7Version, string[]> validVersionCodes = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, string[]> validVersionDescriptions = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, HL7TableType> tableVersionTypes = new Dictionary<HL7Version, HL7TableType>();

        public IdentifierTypeAttribute()
        {
            // init the values for table version types
						tableVersionTypes[HL7Version.v23] = HL7TableType.User;
						tableVersionTypes[HL7Version.v231] = HL7TableType.User;
						tableVersionTypes[HL7Version.v24] = HL7TableType.User;
						tableVersionTypes[HL7Version.v25] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v251] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v26] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v27] = HL7TableType.HL7;
			
            
			// init the values for version codes
						validVersionCodes[HL7Version.v23] = new string[]{"AM","AN","BR","DI","DL","DN","DS","EI","EN","GI","GN","MA","MC","MR","MS","PI","PT","RR","SS","VN","VS","XX"};
						validVersionCodes[HL7Version.v231] = new string[]{"AM","AN","BR","DI","DL","DN","DS","EI","EN","FI","GI","GN","LN","LR","MS","MA","MC","MR","NE","NI","NH","NNxxx","NPI","PI","PN","PRN","PT","RRI","RR","SL","SR","SS","U","UPIN","VS","VN","WC","XX"};
						validVersionCodes[HL7Version.v24] = new string[]{"AM","AN","BA","BR","BRN","DI","DL","DN","DR","DS","EI","EN","FI","GI","GN","HC","JHN","LN","LR","MA","MC","MCN","MR","MS","NE","NH","NI","NNxxx","NPI","PEN","PI","PN","PRN","PT","RR","RRI","SL","SR","SS","U","UPIN","VN","VS","WC","WCN","XX"};
						validVersionCodes[HL7Version.v25] = new string[]{"AM","AN","ANON","ANC","AND","ANT","APRN","BA","BC","BR","BRN","CC","CY","DDS","DEA","DI","DFN","DL","DN","DPM","DO","DR","DS","EI","EN","FI","GI","GL","GN","HC","JHN","IND","LI","LN","LR","MA","MB","MC","MCD","MCN","MCR","MD","MI","MR","MRT","MS","NE","NH","NI","NII","NIIP","NNxxx","NP","NPI","OD","PA","PCN","PE","PEN","PI","PN","PNT","PPN","PRC","PRN","PT","QA","RI","RPH","RN","RR","RRI","SL","SN","SR","SS","TAX","TN","U","UPIN","VN","VS","WC","WCN","XX"};
						validVersionCodes[HL7Version.v251] = new string[]{"AM","AN","ANON","ANC","AND","ANT","APRN","BA","BC","BR","BRN","CC","CY","DDS","DEA","DI","DFN","DL","DN","DPM","DO","DR","DS","EI","EN","FI","GI","GL","GN","HC","JHN","IND","LI","LN","LR","MA","MB","MC","MCD","MCN","MCR","MD","MI","MR","MRT","MS","NE","NH","NI","NII","NIIP","NNxxx","NP","NPI","OD","PA","PCN","PE","PEN","PI","PN","PNT","PPN","PRC","PRN","PT","QA","RI","RPH","RN","RR","RRI","SL","SN","SR","SS","TAX","TN","U","UPIN","VN","VS","WC","WCN","XX"};
						validVersionCodes[HL7Version.v26] = new string[]{"AM","AMA","AN","ANON","ANC","AND","ANT","APRN","BA","BC","BCT","BR","BRN","CC","CONM","CZ","CY","DDS","DEA","DI","DFN","DL","DN","DO","DP","DPM","DR","DS","EI","EN","ESN","FI","GI","GL","GN","HC","JHN","IND","LI","LN","LR","MA","MB","MC","MCD","MCN","MCR","MCT","MD","MI","MR","MRT","MS","NCT","NE","NH","NI","NII","NIIP","NNxxx","NP","NPI","OD","PA","PC","PCN","PE","PEN","PI","PN","PNT","PPIN","PPN","PRC","PRN","PT","QA","RI","RPH","RN","RR","RRI","RRP","SL","SN","SP","SR","SS","TAX","TN","TPR","U","UPIN","VN","VP","VS","WC","WCN","WP","XX"};
						validVersionCodes[HL7Version.v27] = new string[]{"ACSN","AM","AMA","AN","ANON","ANC","AND","ANT","APRN","ASID","BA","BC","BCT","BR","BRN","BSNR","CC","CONM","CZ","CY","DDS","DEA","DI","DFN","DL","DN","DO","DP","DPM","DR","DS","EI","EN","ESN","FI","GI","GL","GN","HC","JHN","IND","LACSN","LANR","LI","LN","LR","MA","MB","MC","MCD","MCN","MCR","MCT","MD","MI","MR","MRT","MS","NBSNR","NCT","NE","NH","NI","NII","NIIP","NNxxx","NP","NPI","OD","PA","PC","PCN","PE","PEN","PI","PN","PNT","PPIN","An Identifier for a provi","PPN","PRC","PRN","PT","QA","RI","RPH","RN","RR","RRI","RRP","SID","SL","SN","SP","SR","SS","TAX","TN","TPR","U","UPIN","USID","VN","VP","VS","WC","WCN","WP","XX"};
			
			// init the values for version descriptions
						validVersionDescriptions[HL7Version.v23] = new string[]{"American Express","Account Number","Birth Registry Number","Diner's Club Card","Driver's License Number","Doctor Number","Discover Card","Employee Number","Employer Number","Guarantor Internal Identifier","Guarantor External Identifier","Medicaid Number","Medicare Number","Medical Record Number","Master Card","Patient Internal Identifier","Patient External Identifier","Railroad Retirement Number","Social Security Number","Visit Number","VISA","Organizaiton Indentifier"};
						validVersionDescriptions[HL7Version.v231] = new string[]{"American Express","Account number","Birth registry number","Diner’s Club card","Driver’s license number","Doctor number","Discover Card","Employee number","Employer number","Facility ID","Guarantor internal identifier","Guarantor external  identifier","License number","Local Registry ID","MasterCard","Medicaid number","Medicare number","Medical record number","National employer identifier","National unique individual identifier","National Health Plan Identifier","National Person Identifier where the xxx is the ISO table 3166  3-character (alphabetic) country  code","National provider identifier","Patient internal identifier","Person number","Provider number","Patient external identifier","Regional registry ID","Railroad Retirement number","State license","State registry ID","Social Security number","Unspecified","Medicare/HCFA’s Universal Physician Identification numbers","VISA","Visit number","WIC identifier","Organization identifier"};
						validVersionDescriptions[HL7Version.v24] = new string[]{"American Express","Account number","Bank Account Number","Birth registry number","Breed Registry Number","Diner's Club card","Driver's license number","Doctor number","Donor Registration Number","Discover Card","Employee number","Employer number","Facility ID","Guarantor internal identifier","Guarantor external  identifier","Health Card Number","Jurisdictional health number (Canada)","License number","Local Registry ID","Medicaid number","Medicare number","Microchip Number","Medical record number","MasterCard","National employer identifier","National Health Plan Identifier","National unique individual identifier","National Person Identifier where the xxx is the ISO table 3166  3-character (alphabetic) country code","National provider identifier","Pension Number","Patient internal identifier","Person number","Provider number","Patient external identifier","Railroad Retirement number","Regional registry ID","State license","State registry ID","Social Security number","Unspecified","Medicare/HCFA's Universal Physician Identification numbers","Visit number","VISA","WIC identifier","Workers' Comp Number","Organization identifier"};
						validVersionDescriptions[HL7Version.v25] = new string[]{"American Express","Account number","Anonymous identifier","Account number Creditor","Account number debitor","Temporary Account Number","Advanced Practice Registered Nurse number","Bank Account Number","Bank Card Number","Birth registry number","Breed Registry Number","Cost Center number","County number","Dentist license number","Drug Enforcement Administration registration number","Diner's Club card","Drug Furnishing or prescriptive authority Number","Driver's license number","Doctor number","Podiatrist license number","Osteopathic License number","Donor Registration Number","Discover Card","Employee number","Employer number","Facility ID","Guarantor internal identifier","General ledger number","Guarantor external  identifier","Health Card Number","Jurisdictional health number (Canada)","Indigenous/Aboriginal","Labor and industries number","License number","Local Registry ID","Patient Medicaid number","Member Number","Patient's Medicare number","Practitioner Medicaid number","Microchip Number","Practitioner Medicare number","Medical License number","Military ID number","Medical record number","Temporary Medical Record Number","MasterCard","National employer identifier","National Health Plan Identifier","National unique individual identifier","National Insurance Organization Identifier","National Insurance Payor Identifier (Payor)","National Person Identifier where the xxx is the ISO table 3166 3-character (alphabetic) country code","Nurse practitioner number","National provider identifier","Optometrist license number","Physician Assistant number","Penitentiary/correctional institution Number","Living Subject Enterprise Number","Pension Number","Patient internal identifier","Person number","Temporary Living Subject Number","Passport number","Permanent Resident Card Number","Provider number","Patient external identifier","QA number","Resource identifier","Pharmacist license number","Registered Nurse Number","Railroad Retirement number","Regional registry ID","State license","Subscriber Number","State registry ID","Social Security number","Tax ID number","Treaty Number/ (Canada)","Unspecified identifier","Medicare/CMS (formerly HCFA)'s Universal Physician Identification numbers","Visit number","VISA","WIC identifier","Workers' Comp Number","Organization identifier"};
						validVersionDescriptions[HL7Version.v251] = new string[]{"American Express","Account number","Anonymous identifier","Account number Creditor","Account number debitor","Temporary Account Number","Advanced Practice Registered Nurse number","Bank Account Number","Bank Card Number","Birth registry number","Breed Registry Number","Cost Center number","County number","Dentist license number","Drug Enforcement Administration registration number","Diner's Club card","Drug Furnishing or prescriptive authority Number","Driver's license number","Doctor number","Podiatrist license number","Osteopathic License number","Donor Registration Number","Discover Card","Employee number","Employer number","Facility ID","Guarantor internal identifier","General ledger number","Guarantor external  identifier","Health Card Number","Jurisdictional health number (Canada)","Indigenous/Aboriginal","Labor and industries number","License number","Local Registry ID","Patient Medicaid number","Member Number","Patient's Medicare number","Practitioner Medicaid number","Microchip Number","Practitioner Medicare number","Medical License number","Military ID number","Medical record number","Temporary Medical Record Number","MasterCard","National employer identifier","National Health Plan Identifier","National unique individual identifier","National Insurance Organization Identifier","National Insurance Payor Identifier (Payor)","National Person Identifier where the xxx is the ISO table 3166 3-character (alphabetic) country code","Nurse practitioner number","National provider identifier","Optometrist license number","Physician Assistant number","Penitentiary/correctional institution Number","Living Subject Enterprise Number","Pension Number","Patient internal identifier","Person number","Temporary Living Subject Number","Passport number","Permanent Resident Card Number","Provider number","Patient external identifier","QA number","Resource identifier","Pharmacist license number","Registered Nurse Number","Railroad Retirement number","Regional registry ID","State license","Subscriber Number","State registry ID","Social Security number","Tax ID number","Treaty Number/ (Canada)","Unspecified identifier","Medicare/CMS (formerly HCFA)'s Universal Physician Identification numbers","Visit number","VISA","WIC identifier","Workers' Comp Number","Organization identifier"};
						validVersionDescriptions[HL7Version.v26] = new string[]{"American Express","American Medical Association Number","Account number","Anonymous identifier","Account number Creditor","Account number debitor","Temporary Account Number","Advanced Practice Registered Nurse number","Bank Account Number","Bank Card Number","Birth Certificate","Birth registry number","Breed Registry Number","Cost Center number","Change of Name Document","Citizenship Card","County number","Dentist license number","Drug Enforcement Administration registration number","Diner's Club card","Drug Furnishing or prescriptive authority Number","Driver's license number","Doctor number","Osteopathic License number","Diplomatic Passport","Podiatrist license number","Donor Registration Number","Discover Card","Employee number","Employer number","Staff Enterprise Number","Facility ID","Guarantor internal identifier","General ledger number","Guarantor external  identifier","Health Card Number","Jurisdictional health number (Canada)","Indigenous/Aboriginal","Labor and industries number","License number","Local Registry ID","Patient Medicaid number","Member Number","Patient's Medicare number","Practitioner Medicaid number","Microchip Number","Practitioner Medicare number","Marriage Certificate","Medical License number","Military ID number","Medical record number","Temporary Medical Record Number","MasterCard","Naturalization Certificate","National employer identifier","National Health Plan Identifier","National unique individual identifier","National Insurance Organization Identifier","National Insurance Payor Identifier (Payor)","National Person Identifier where the xxx is the ISO table 3166 3-character (alphabetic) country code","Nurse practitioner number","National provider identifier","Optometrist license number","Physician Assistant number","Parole Card","Penitentiary/correctional institution Number","Living Subject Enterprise Number","Pension Number","Patient internal identifier","Person number","Temporary Living Subject Number","Medicare/CMS Performing Provider Identification Number","Passport number","Permanent Resident Card Number","Provider number","Patient external identifier","QA number","Resource identifier","Pharmacist license number","Registered Nurse Number","Railroad Retirement number","Regional registry ID","Railroad Retirement Provider","State license","Subscriber Number","Study Permit","State registry ID","Social Security number","Tax ID number","Treaty Number/ (Canada)","Temporary Permanent Resident (Canada)","Unspecified identifier","Medicare/CMS (formerly HCFA)'s Universal Physician Identification numbers","Visit number","Visitor Permit","VISA","WIC identifier","Workers' Comp Number","Work Permit","Organization identifier"};
						validVersionDescriptions[HL7Version.v27] = new string[]{"Accession ID","American Express","American Medical Association Number","Account number","Anonymous identifier","Account number Creditor","Account number debitor","Temporary Account Number","Advanced Practice Registered Nurse number","Ancestor Specimen ID","Bank Account Number","Bank Card Number","Birth Certificate","Birth registry number","Breed Registry Number","Primary physician office number","Cost Center number","Change of Name Document","Citizenship Card","County number","Dentist license number","Drug Enforcement Administration registration number","Diner's Club card","Drug Furnishing or prescriptive authority Number","Driver's license number","Doctor number","Osteopathic License number","Diplomatic Passport","Podiatrist license number","Donor Registration Number","Discover Card","Employee number","Employer number","Staff Enterprise Number","Facility ID","Guarantor internal identifier","General ledger number","Guarantor external  identifier","Health Card Number","Jurisdictional health number (Canada)","Indigenous/Aboriginal","Laboratory Accession ID","Lifelong physician number","Labor and industries number","License number","Local Registry ID","Patient Medicaid number","Member Number","Patient's Medicare number","Practitioner Medicaid number","Microchip Number","Practitioner Medicare number","Marriage Certificate","Medical License number","Military ID number","Medical record number","Temporary Medical Record Number","MasterCard","Secondary physician office number","Naturalization Certificate","National employer identifier","National Health Plan Identifier","National unique individual identifier","National Insurance Organization Identifier","National Insurance Payor Identifier (Payor)","National Person Identifier where the xxx is the ISO table 3166 3-character (alphabetic) country code","Nurse practitioner number","National provider identifier","Optometrist license number","Physician Assistant number","Parole Card","Penitentiary/correctional institution Number","Living Subject Enterprise Number","Pension Number","Patient internal identifier","Person number","Temporary Living Subject Number","Medicare/CMS Performing Provider Identification Number","","Passport number","Permanent Resident Card Number","Provider number","Patient external identifier","QA number","Resource identifier","Pharmacist license number","Registered Nurse Number","Railroad Retirement number","Regional registry ID","Railroad Retirement Provider","Specimen ID","State license","Subscriber Number","Study Permit","State registry ID","Social Security number","Tax ID number","Treaty Number/ (Canada)","Temporary Permanent Resident (Canada)","Unspecified identifier","Medicare/CMS (formerly HCFA)'s Universal Physician Identification numbers","Unique Specimen ID","Visit number","Visitor Permit","VISA","WIC identifier","Workers' Comp Number","Work Permit","Organization identifier"};
			            

        }

        
        public override ValidationIssue[] RunRule(string name, object owningObject, object value)
        {
            //todo: check if the value is valid in the current version
            //if the value is not valid in the current version, add it as a validation issue


            return new ValidationIssue[0];
        }
    }
}
